import React, { useRef, useEffect, forwardRef } from 'react'
import { useGLTF, useAnimations } from '@react-three/drei'

const Gift = forwardRef((props, ref) => {
  const { nodes, materials, animations } = useGLTF('/models/gift.glb')
  const { actions } = useAnimations(animations, ref)
  useEffect(() => {
    for (const k in actions) {
      actions[k].play()
    }
  }, [actions]);
  return (
    <group visible={true} ref={ref} scale={1} dispose={null} position={0} >
      <group name="Sketchfab_Scene">
        <group name="RootNode" scale={0.01}>
          <group name="Steam_01" position={[3.70771, 75.91478, -29.013687]} rotation={[0, -Math.PI / 6, -Math.PI / 2]} scale={0}>
            <mesh name="Steam_01_Steam_0" geometry={nodes.Steam_01_Steam_0.geometry} material={materials.Steam} />
          </group>
          <group name="Steam_02" position={[-22.57222, 75.91478, -16.903805]} rotation={[0, -Math.PI / 6, -Math.PI / 2]} scale={0}>
            <mesh name="Steam_02_Steam_0" geometry={nodes.Steam_02_Steam_0.geometry} material={materials.Steam} />
          </group>
          <group name="Steam_03" position={[-52.737137, 75.91478, -8.667236]} rotation={[Math.PI / 2, 0, -1.308997]} scale={0}>
            <mesh name="Steam_03_Steam_0" geometry={nodes.Steam_03_Steam_0.geometry} material={materials.Steam} />
          </group>
          <group name="Steam_00" position={[-96.524895, 65.873283, -3.934572]} scale={0}>
            <mesh name="Steam_00_Steam_0" geometry={nodes.Steam_00_Steam_0.geometry} material={materials.Steam} />
          </group>
          <group name="KeyAnimGRP" position={[-5.818612, 0.869446, 34.674492]} rotation={[0, -0.837615, 0]}>
            <group name="Key" position={[0.288247, 0.004236, 0.003587]}>
              <mesh name="Key_Props_0" geometry={nodes.Key_Props_0.geometry} material={materials.Props} />
            </group>
          </group>
        </group>
        <group name="Chest_Final" position={[1.575809, 0, -0.739675]} rotation={[0, 0.345968, 0]} scale={0.01}>
          <group name="Lid" position={[-190.079651, 58.696739, -34.766998]} rotation={[Math.PI / 2, 0, 0]}>
            <group name="Cap_03" position={[-29.920349, 24.877588, -16.491396]}>
              <mesh name="Cap_03_Parts_01_0" geometry={nodes.Cap_03_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="Cap_02" position={[0.079651, 24.877588, -16.491396]}>
              <mesh name="Cap_02_Parts_01_0" geometry={nodes.Cap_02_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="Cap_01" position={[30.079651, 24.877588, -16.491396]}>
              <mesh name="Cap_01_Parts_01_0" geometry={nodes.Cap_01_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="LockPin_01" position={[-43.749683, 44.87759, 0.859368]}>
              <mesh name="LockPin_01_Parts_01_0" geometry={nodes.LockPin_01_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="LockPin_02" position={[-43.731388, 34.87759, 0.859368]}>
              <mesh name="LockPin_02_Parts_01_0" geometry={nodes.LockPin_02_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="LockPin_03" position={[-43.552616, 24.877588, 0.859368]}>
              <mesh name="LockPin_03_Parts_01_0" geometry={nodes.LockPin_03_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="Latch_01" position={[-29.920349, 72.597389, -3.89694]}>
              <mesh name="Latch_01_Parts_01_0" geometry={nodes.Latch_01_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="Latch_02" position={[0.079651, 72.597389, -3.89694]}>
              <mesh name="Latch_02_Parts_01_0" geometry={nodes.Latch_02_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="Latch_03" position={[30.079651, 72.597389, -3.89694]}>
              <mesh name="Latch_03_Parts_01_0" geometry={nodes.Latch_03_Parts_01_0.geometry} material={materials.Parts_01} />
            </group>
            <group name="Rod_02" position={[0.079651, 69.907867, -1.804766]}>
              <mesh name="Rod_02_Gears_0" geometry={nodes.Rod_02_Gears_0.geometry} material={materials.Gears} />
            </group>
            <group name="Small_Gear_05" position={[40.3265, 69.032661, -6.440721]}>
              <mesh name="Small_Gear_05_Gears_0" geometry={nodes.Small_Gear_05_Gears_0.geometry} material={materials.Gears} />
            </group>
            <group name="Small_Gear_04" position={[36.290611, 69.553139, -5.487135]}>
              <mesh name="Small_Gear_04_Gears_0" geometry={nodes.Small_Gear_04_Gears_0.geometry} material={materials.Gears} />
            </group>
            <mesh name="Lid_Intiror_0" geometry={nodes.Lid_Intiror_0.geometry} material={materials.Intiror} />
            <mesh name="Lid_Parts_01_0" geometry={nodes.Lid_Parts_01_0.geometry} material={materials.Parts_01} />
          </group>
          <group name="Piston_02" position={[-190, 13.103301, 0]}>
            <mesh name="Piston_02_Intiror_0" geometry={nodes.Piston_02_Intiror_0.geometry} material={materials.Intiror} />
          </group>
          <group name="Piston_01" position={[-190, 14.949775, 0]}>
            <mesh name="Piston_01_Intiror_0" geometry={nodes.Piston_01_Intiror_0.geometry} material={materials.Intiror} />
          </group>
          <group name="Big_Gear_02" position={[-190.004425, 37.780384, 26.954124]}>
            <mesh name="Big_Gear_02_Gears_0" geometry={nodes.Big_Gear_02_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Needle_02" position={[-139.637711, 30.932407, 9.706027]} rotation={[-Math.PI / 4, 0, 0]}>
            <mesh name="Needle_02_Intiror_0" geometry={nodes.Needle_02_Intiror_0.geometry} material={materials.Intiror} />
          </group>
          <group name="Needle_01" position={[-139.933472, 43.69104, -9.003827]} rotation={[-Math.PI / 6, 0, 0]}>
            <mesh name="Needle_01_Intiror_0" geometry={nodes.Needle_01_Intiror_0.geometry} material={materials.Intiror} />
          </group>
          <group name="Big_Gear_03" position={[-159.760254, 44.784508, 26.732944]}>
            <mesh name="Big_Gear_03_Gears_0" geometry={nodes.Big_Gear_03_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Small_Gear_03" position={[-160.50148, 44.784508, 28.55365]}>
            <mesh name="Small_Gear_03_Gears_0" geometry={nodes.Small_Gear_03_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Big_Gear_05" position={[-237.76825, 34.527313, 18.522289]}>
            <mesh name="Big_Gear_05_Gears_0" geometry={nodes.Big_Gear_05_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Med_Gear_03" position={[-226.542816, 37.881329, 27.667238]}>
            <mesh name="Med_Gear_03_Gears_0" geometry={nodes.Med_Gear_03_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Med_Gear_02" position={[-212.275375, 44.784508, 27.233496]}>
            <mesh name="Med_Gear_02_Gears_0" geometry={nodes.Med_Gear_02_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Small_Gear_02" position={[-212.275299, 44.784508, 28.973072]}>
            <mesh name="Small_Gear_02_Gears_0" geometry={nodes.Small_Gear_02_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Big_Gear_04" position={[-210.935287, 22.175776, 26.954124]}>
            <mesh name="Big_Gear_04_Gears_0" geometry={nodes.Big_Gear_04_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Med_Gear_04" position={[-237.936554, 27.799879, 4.33836]}>
            <mesh name="Med_Gear_04_Gears_0" geometry={nodes.Med_Gear_04_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Med_Gear_05" position={[-240.450851, 45.094112, 4.741374]}>
            <mesh name="Med_Gear_05_Gears_0" geometry={nodes.Med_Gear_05_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Big_Gear_06" position={[-239.949173, 27.799917, 4.33836]}>
            <mesh name="Big_Gear_06_Gears_0" geometry={nodes.Big_Gear_06_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Rod_01" position={[-196.060898, 47.794014, 28.825733]}>
            <mesh name="Rod_01_Gears_0" geometry={nodes.Rod_01_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Spring_01" position={[-238.059326, 54.840183, 8.716207]}>
            <mesh name="Spring_01_Gears_0" geometry={nodes.Spring_01_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Spring_02" position={[-238.059326, 52.6604, 11.702677]}>
            <mesh name="Spring_02_Gears_0" geometry={nodes.Spring_02_Gears_0.geometry} material={materials.Gears} />
          </group>
          <group name="Cap" position={[-190, 27.420725, 0]} rotation={[0, Math.PI / 2, 0]}>
            <mesh name="Cap_Intiror_0" geometry={nodes.Cap_Intiror_0.geometry} material={materials.Intiror} />
            <mesh name="Cap_Glass_0" geometry={nodes.Cap_Glass_0.geometry} material={materials.Glass} />
          </group>
        </group>
        <mesh name="Pen_Props_0" geometry={nodes.Pen_Props_0.geometry} material={materials.Props} position={[0.274479, 0.124242, 1.588583]} rotation={[-0.138319, 1.21894, 0.122173]} scale={0.01} />
        <mesh name="Body_Base_0" geometry={nodes.Body_Base_0.geometry} material={materials.Base} position={[-0.211611, 0, -0.09537]} rotation={[0, 0.345968, 0]} scale={0.01} />
        <mesh name="Body_Parts_01_0" geometry={nodes.Body_Parts_01_0.geometry} material={materials.Parts_01} position={[-0.211611, 0, -0.09537]} rotation={[0, 0.345968, 0]} scale={0.01} />
        <mesh name="Body_Intiror_0" geometry={nodes.Body_Intiror_0.geometry} material={materials.Intiror} position={[-0.211611, 0, -0.09537]} rotation={[0, 0.345968, 0]} scale={0.01} />
        <mesh name="Body_Glass_0" geometry={nodes.Body_Glass_0.geometry} material={materials.Glass} position={[-0.211611, 0, -0.09537]} rotation={[0, 0.345968, 0]} scale={0.01} />
        <mesh name="Big_Gear_17_Gears_0" geometry={nodes.Big_Gear_17_Gears_0.geometry} material={materials.Gears} position={[2.252645, -0.26859, -0.010598]} rotation={[-Math.PI / 2, 0, 0.345968]} scale={0.01} />
      </group>
    </group>
  )
})

useGLTF.preload('/models/gift.glb')

export default Gift;
